/*
 * FileName：SohuNewsJob.java 
 * <p>
 * Copyright (c) 2017-2020 <a href="https://www.smartwx.info">hermit(1154808491@qq.com)</a>.
 * <p>
 * Licensed under the GNU General Public License, Version 3 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.gnu.org/licenses/gpl-3.0.html
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package com.smart.quartz.job;

import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * 爬取搜狐新闻
 */
public class SohuNewsJob implements  Job,Serializable {
    
	private static final Logger logger = LoggerFactory.getLogger(SohuNewsJob.class);
	private static final long serialVersionUID = 1L;

	@Override
	public void execute(JobExecutionContext context) {

        logger.info("开始爬取搜狐热门新闻" + LocalDateTime.now());
		 //取得job详情
         JobDetail jobDetail = context.getJobDetail();     
         // 取得job名称  
         String jobName = jobDetail.getClass().getName();  
         logger.info("Name: " + jobDetail.getClass().getSimpleName());     
         //取得job的类  
         logger.info("Job Class: " + jobDetail.getJobClass());     
         //取得job开始时间  
         logger.info(jobName + " fired at " + context.getFireTime());     
         //取得job下次触发时间  
         logger.info("Next fire time " + context.getNextFireTime());  
         
         JobDataMap dataMap =  jobDetail.getJobDataMap();
         
         logger.info("title: " + dataMap.getString("title"));
         logger.info("url: " + dataMap.getString("url"));
	}
}
